class TictactoeServer:
    def __init__(self) -> None:
        # checkerboard 初始状态为 0，player1 为 1，player_2 为 2
        self.checkerboard = [0] * 9
        self.index_ = 0

    def start_game(self):
        self._init()

    def init(self):
        self.checkerboard = [0] * 9
        self.index_ = 0

    def _game_over(self):
        pass

    def _is_horizontal_same_line(self):
        find_vec = [0, 3, 6]
        for num in find_vec:
            if not self.checkerboard[num] == self.checkerboard[num + 1] == self.checkerboard[num + 2]:
                return False
        return True

    def _is_vertical_same_line(self):
        find_vec = [0, 1, 2]
        for num in find_vec:
            if not self.checkerboard[num] == self.checkerboard[num + 3] == self.checkerboard[num + 6]:
                return False
        return True

    def _is_slant_same_line(self):
        return self.checkerboard[0] == self.checkerboard[4] == self.checkerboard[8] or \
               self.checkerboard[2] == self.checkerboard[4] == self.checkerboard[6]

    def _refresh_checkerboard(self, pos):
        self.checkerboard[pos] = 1 if (self.index_ & 1) == 0 else 2
